<template>
  <base-breadcrumb :breadcrumb="!isAudit">
    <a-form-model
      :model="form"
      :rules="rules"
      ref="ruleForm"
      :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
      :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
    >
      <a-spin :spinning="progressing">
        <a-card
          :body-style="{ padding: '24px 32px' }"
          :bordered="false"
        >
          <title-name :title="`${curTitle}设计资源推荐`"></title-name>

          <div>
            <a-tabs
              ref="tabs"
              :activeKey="nextSteps"
              @change="callback"
            >
              <a-tab-pane
                key="1"
                tab="基本信息"
              >
                <a-col
                  :md="8"
                  :sm="8"
                >
                  <a-form-model-item
                    label="推荐设计资源名称"
                    prop="resName"
                  >
                    <BaseInput
                      v-model="form.resName"
                      :disabled="type == 'view' || type == 'approve' || isAudit"
                      placeholder="请输入"
                    ></BaseInput>
                  </a-form-model-item>
                </a-col>
                <a-col
                  :md="8"
                  :sm="8"
                >
                  <a-form-model-item
                    label="推荐类型"
                    prop="resTypeId"
                  >
                    <a-select
                      :disabled="type == 'view' || type == 'approve' || isAudit"
                      v-model="form.resTypeId"
                      @change="changeType"
                      placeholder="请选择"
                    >
                      <a-select-option
                        v-for="item in typeList"
                        :key="item.id"
                        :value="item.id"
                      >
                        {{ item.name }}</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <a-col
                  :md="8"
                  :sm="8"
                >
                  <a-form-model-item
                    label="推荐评级"
                    prop="resLevelId"
                  >
                    <a-select
                      :disabled="type == 'view' || type == 'approve' || isAudit"
                      placeholder="请选择"
                      v-model="form.resLevelId"
                    >
                      <a-select-option
                        v-for="item in recommendLevelOption"
                        :key="item.id"
                        :value="item.id"
                      >{{
                        item.name
                      }}</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <a-col
                  :md="8"
                  :sm="8"
                >
                  <a-form-model-item
                    label="推荐人"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                  >
                    <BaseInput
                      v-model="form.recommendEmployeeName"
                      disabled
                    ></BaseInput>
                  </a-form-model-item>
                </a-col>
                <!-- 新增 (分公司权限) -->
                <a-col
                  :md="8"
                  :sm="8"
                  v-if="branchLevel && !companyLevel && type=='add' &&  type !='approve' "
                >
                  <a-form-model-item
                    label="推荐单位"
                    prop="recommendOrgId"
                  >
                    <a-select
                      :disabled="type == 'view' || type == 'approve' || isAudit || type=='edit'"
                      @change="handleChangeCompany"
                      v-model="form.recommendOrgId"
                      placeholder="请选择"
                    >
                      <a-select-option
                        v-for="item in branchList"
                        :key="item.id"
                        :value="item.id"
                      >{{
                        item.name
                      }}</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <!-- 编辑，查看（分公司权限） -->
                <a-col
                  :md="8"
                  :sm="8"
                  v-if="type!='add' && form.recommendOrgCode== 'BC'&&  type !='approve'"
                >
                  <a-form-model-item
                    label="推荐单位"
                    prop="recommendOrgId"
                  >
                    <a-select
                      :disabled="type == 'view' || type == 'approve' || isAudit || type=='edit'"
                      @change="handleChangeCompany"
                      v-model="form.recommendOrgId"
                      placeholder="请选择"
                    >
                      <a-select-option
                        v-for="item in branchList"
                        :key="item.id"
                        :value="item.id"
                      >{{
                        item.name
                      }}</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <!-- 新增（公司权限） -->
                <a-col
                  :md="8"
                  :sm="8"
                  v-if="companyLevel && type=='add'&&  type !='approve'"
                >
                  <a-form-model-item
                    label="推荐单位"
                    prop="recommendOrgId"
                  >
                    <!-- <BaseInput disabled v-model="form.recommendOrgName"></BaseInput> -->
                    <a-select
                      :disabled="type == 'view' || type == 'approve' || isAudit || type=='edit'"
                      @change="handleChangeCompany"
                      v-model="form.recommendOrgId"
                      placeholder="请选择"
                    >
                      <a-select-option
                        v-for="item in companyLists"
                        :key="item.id"
                        :value="item.id"
                      >{{
                        item.name
                      }}</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <!-- 编辑，查看（公司权限） -->
                <a-col
                  :md="8"
                  :sm="8"
                  v-if="type!='add' && form.recommendOrgCode== 'CO'&&  type !='approve'"
                >
                  <a-form-model-item
                    label="推荐单位"
                    prop="recommendOrgId"
                  >
                    <!-- <BaseInput disabled v-model="form.recommendOrgName"></BaseInput> -->
                    <a-select
                      :disabled="type == 'view' || type == 'approve' || isAudit || type=='edit'"
                      @change="handleChangeCompany"
                      v-model="form.recommendOrgId"
                      placeholder="请选择"
                    >
                      <a-select-option
                        v-for="item in companyLists"
                        :key="item.id"
                        :value="item.id"
                      >{{
                        item.name
                      }}</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <a-col
                  :md="8"
                  :sm="8"
                  v-if="type=='approve'"
                >
                  <a-form-model-item
                    label="推荐单位"
                    prop="recommendOrgId"
                  >
                    <BaseInput
                      disabled
                      v-model="form.recommendOrgName"
                    ></BaseInput>
                  </a-form-model-item>
                </a-col>
                <a-col
                  :md="8"
                  :sm="8"
                >
                  <a-form-model-item
                    label="创建时间"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
                  >
                    <BaseInput
                      v-model="form.createTime"
                      disabled
                      placeholder="请输入"
                    />
                  </a-form-model-item>
                </a-col>
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-model-item
                    label="推荐理由"
                    prop="recommendReason"
                  >
                    <BaseTextarea
                      :disabled="type == 'view' || type == 'approve' || isAudit"
                      v-model="form.recommendReason"
                      placeholder="请输入"
                      :maxLength="300"
                    />
                  </a-form-model-item>
                </a-col>

                <a-button
                  style="float: right; margin-right: 10px"
                  @click="nextStep()"
                  type="primary"
                >下一步</a-button>

                <div v-if="!isConsultation" class="page-btn-right-top">
                  <a-button
                    v-if="type !== 'approve'"
                    :disabled="type == 'view'"
                    style="margin: 0 10px"
                    type="primary"
                    :loading="loadingGroup.saveDraft"
                    @click="saveDraft(true)"
                  >保存草稿</a-button>
                  <a-button
                    v-if="type !== 'approve'"
                    :loading="loadingGroup.submitForm"
                    :disabled="type == 'view'"
                    type="primary"
                    @click="submitForm"
                  >提交</a-button>
                  <a-button
                    style="margin: 0 10px"
                    type="primary"
                    @click="goBack"
                  >关闭</a-button>
                </div>
              </a-tab-pane>

              <a-tab-pane
                key="2"
                tab="推荐信息"
              >
                <!-- <design-company v-if="formType=='设计单位'"></design-company> -->
                <div v-if="formType == '设计单位'">
                  <title-name title="推荐设计单位信息"></title-name>
                  <a-form-model
                    :model="formList"
                    :rules="companyRules"
                    ref="companyForm"
                  >
                    <a-row>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="推荐设计资源名称"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            placeholder="请输入"
                            disabled
                            v-model="formList.resName"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="统一社会信用代码"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                          prop="creditCode"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.creditCode"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="企业人数"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInputNumber
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            :min="1"
                            placeholder="请输入"
                            v-model="formList.employeeNum"
                          ></BaseInputNumber>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="企业性质"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <a-select
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请选择"
                            v-model="formList.natureOfEnterpriseId"
                          >
                            <a-select-option
                              v-for="item in companyList"
                              :key="item.id"
                              :value="item.id"
                            >{{
                              item.name
                            }}</a-select-option>
                          </a-select>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="公司注册时间"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <a-date-picker
                            placeholder="请选择"
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            v-model="formList.registrationDate"
                            @change="changeTime"
                          ></a-date-picker>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="注册资金(万)"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInputNumber
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            :min="1"
                            placeholder="请输入"
                            v-model="formList.registeredCapital"
                          ></BaseInputNumber>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="企业法人代表姓名"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.legalName"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="法人代表电话"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.legalContact"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="24"
                        :sm="24"
                      >
                        <a-form-model-item
                          label="企业地址"
                          :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                          :wrapperCol="{ lg: { span: 19 }, sm: { span: 19 } }"
                        >
                          <BaseTextarea
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.address"
                          ></BaseTextarea>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="24"
                        :sm="24"
                      >
                        <a-form-model-item
                          label="专业技术人员配备情况"
                          :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                          help="如推荐企业所属下级团队，填写团队情况"
                        >
                          <BaseTextarea
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.techStaff"
                          ></BaseTextarea>
                        </a-form-model-item>
                      </a-col>
                    </a-row>
                  </a-form-model>
                  <title-name title="资质证书"></title-name>
                  <a-row style="margin-bottom: 10px">
                    <a-button
                      :disabled="type == 'view' || type == 'approve' || isAudit"
                      style="margin-right: 10px"
                      type="primary"
                      @click="addQulList"
                    >新增</a-button>
                    <a-button
                      :disabled="type == 'view' || type == 'approve' || isAudit"
                      @click="goDel"
                    >删除</a-button>
                  </a-row>
                  <a-table
                    rowKey="id"
                    :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
                    :data-source="formList.certifications"
                    :columns="columns"
                  >
                    <span
                      slot="serial"
                      slot-scope="text, record, index"
                    >{{ index + 1 }}</span>
                    <span
                      slot="action"
                      slot-scope="text, record, index"
                    >
                      <template>
                        <a
                          v-if="type != 'view' && type != 'approve'"
                          @click="handleQulEdit(record, index)"
                        >编辑</a>
                      </template>
                    </span>
                  </a-table>
                </div>
                <!-- <design-expert :formType="formType" v-if="formType=='设计专家'"></design-expert> -->
                <div v-if="formType == '设计专家'">
                  <title-name title="推荐设计专家信息"></title-name>
                  <a-form-model
                    :model="formList"
                    :rules="expertRules"
                    ref="expertForm"
                  >
                    <a-row>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="推荐设计资源名称"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            placeholder="请输入"
                            disabled
                            v-model="formList.resName"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="工作单位"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.employer"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <!-- <a-col :md='8' :sm="8">
                          <div > -->
                      <a-button
                        :disabled="type == 'view' || type == 'approve' || isAudit"
                        style="margin-left: 20px"
                        type="primary"
                        @click="clickBtn"
                      >选择</a-button><span style="font-size: 12px">(从设计资源库中选择)</span>
                      <!-- </div>
                        </a-col> -->
                    </a-row>
                    <a-row>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="联系电话"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.tel"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="邮箱"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                          prop="email"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.email"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="毕业院校"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.graduateSchool"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="最高学历"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <a-select
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请选择"
                            v-model="formList.maxEducationId"
                          >
                            <a-select-option
                              v-for="item in educationList"
                              :key="item.id"
                            >{{
                              item.name
                            }}</a-select-option>
                          </a-select>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="专业"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.profession"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="工作年限"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInputNumber
                            :min="0"
                            :maxLength='2'
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.workYears"
                          ></BaseInputNumber>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="职称"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <a-select
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请选择"
                            v-model="formList.jobTitleId"
                          >
                            <a-select-option
                              v-for="item in titleList"
                              :key="item.id"
                            >{{ item.name }}</a-select-option>
                          </a-select>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="所属专家库名称"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.expertLib"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="24"
                        :sm="24"
                      >
                        <a-form-model-item
                          label="注册证书情况"
                          :labelCol="{ lg: { span: 2 }, sm: { span: 2 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseTextarea
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            :maxLength='300'
                            placeholder="请输入"
                            v-model="formList.certificate"
                          ></BaseTextarea>
                        </a-form-model-item>
                      </a-col>
                    </a-row>
                  </a-form-model>
                </div>
                <!-- <overseas-company v-if="formType=='海外设计单位'"></overseas-company> -->
                <div v-if="formType == '海外设计单位'">
                  <title-name title="推荐海外设计单位信息"></title-name>
                  <a-form-model
                    :model="formList"
                    :rules="overseasRules"
                    ref="overseasForm"
                  >
                    <a-row>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="推荐设计资源名称"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            placeholder="请输入"
                            disabled
                            v-model="formList.resName"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="企业代码"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.creditCode"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="企业人数"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInputNumber
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            :min="1"
                            placeholder="请输入"
                            v-model="formList.employeeNum"
                          ></BaseInputNumber>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="企业性质"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.nature"
                          ></BaseInput>
                          <!-- <a-select v-model="formList">
                              <a-select-option v-for="item in typeList" :key="item.id">{{item.name}}</a-select-option>
                            </a-select> -->
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="公司注册时间"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <!-- <BaseInput placeholder="请输入"  v-model="formList.time"></BaseInput> -->
                          <a-date-picker
                            placeholder="请选择"
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            v-model="formList.registrationDate"
                            @change="changeTime"
                          ></a-date-picker>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="法定资本(万)"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInputNumber
                            :min="1"
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.registeredCapital"
                          ></BaseInputNumber>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="企业法人代表姓名"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.legalName"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="法人代表电话"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.legalContact"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="24"
                        :sm="24"
                      >
                        <a-form-model-item
                          label="企业地址"
                          :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                          :wrapperCol="{ lg: { span: 19 }, sm: { span: 19 } }"
                        >
                          <BaseTextarea
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.address"
                          ></BaseTextarea>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="24"
                        :sm="24"
                      >
                        <a-form-model-item
                          label="承揽项目范围"
                          :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseTextarea
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.projectScope"
                          ></BaseTextarea>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="24"
                        :sm="24"
                      >
                        <a-form-model-item
                          label="专业技术人员配备情况"
                          :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                          help="如推荐企业所属下级团队，填写团队情况"
                        >
                          <BaseTextarea
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.techStaff"
                          ></BaseTextarea>
                        </a-form-model-item>
                      </a-col>
                    </a-row>
                  </a-form-model>
                </div>
                <!-- <overseas-expert v-if="formType=='海外设计专家'"></overseas-expert> -->
                <div v-if="formType == '海外设计专家'">
                  <title-name title="推荐海外设计专家信息"></title-name>
                  <a-form-model
                    :model="formList"
                    :rules="overseasExpertRules"
                    ref="overseasExpertForm"
                  >
                    <a-row>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="推荐设计资源名称"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            placeholder="请输入"
                            disabled
                            v-model="formList.resName"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="工作单位"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type != 'edit'"
                            placeholder="请输入"
                            v-model="formList.employer"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <!-- <a-col :md='8' :sm="8">
                          <div > -->
                      <a-button
                        :disabled="type == 'view' || type == 'approve' || isAudit"
                        style="margin-left: 20px"
                        type="primary"
                        @click="clickBtn"
                      >选择</a-button><span style="font-size: 12px">(从设计资源库中选择)</span>
                      <!-- </div>
                        </a-col> -->
                    </a-row>
                    <a-row>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="联系电话"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.tel"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="邮箱"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                          prop="email"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.email"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="毕业院校"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.graduateSchool"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="最高学历"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <a-select
                            placeholder="请选择"
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            v-model="formList.maxEducationId"
                          >
                            <a-select-option
                              v-for="item in educationList"
                              :key="item.id"
                            >{{
                              item.name
                            }}</a-select-option>
                          </a-select>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="专业"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInput
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.profession"
                          ></BaseInput>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="8"
                        :sm="8"
                      >
                        <a-form-model-item
                          label="工作年限"
                          :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseInputNumber
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            :min='0'
                            :maxLength='2'
                            v-model="formList.workYears"
                          ></BaseInputNumber>
                        </a-form-model-item>
                      </a-col>
                      <a-col
                        :md="24"
                        :sm="24"
                      >
                        <a-form-model-item
                          label="注册证书情况"
                          :labelCol="{ lg: { span: 2 }, sm: { span: 2 } }"
                          :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                        >
                          <BaseTextarea
                            :disabled="type == 'view' || type == 'approve' || isAudit"
                            placeholder="请输入"
                            v-model="formList.certificate"
                          ></BaseTextarea>
                        </a-form-model-item>
                      </a-col>
                    </a-row>
                  </a-form-model>
                </div>
                <!-- class="page-btn-right-top" -->
                <div v-if="!isConsultation" class="page-btn-right-top">
                  <a-button
                    class="ml12"
                    :loading="loadingGroup.save"
                    v-if="type != 'view' && type != 'approve'"
                    @click="save(true)"
                    type="primary"
                  >保存草稿</a-button>
                  <a-button
                    class="ml12"
                    :loading="loadingGroup.submit"
                    v-if="type != 'view' && type != 'approve'"
                    @click="submit()"
                    type="primary"
                  >提交</a-button>
                  <a-button
                    class="ml12"
                    @click="goBack()"
                    type="primary"
                  >关闭</a-button>
                </div>
              </a-tab-pane>
            </a-tabs>
          </div>
        </a-card>
      </a-spin>
    </a-form-model>

    <!-- 资质证书 -->
    <a-modal
      title="新增资质证书"
      :visible="visible"
      :confirm-loading="confirmLoading"
      width="1000px"
      @ok="handleOk"
      @cancel="handleCancel"
    >
      <a-form-model
        ref="certForm"
        :model="formAdd"
        :rules="certRules"
      >
        <a-row>
          <a-col
            :md="12"
            :sm="12"
          >
            <a-form-model-item
              label="资质类别"
              :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
              :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
              prop="certType"
            >
              <BaseInput
                v-model="formAdd.certType"
                :disabled="type == 'view'"
                placeholder="请输入"
              />
            </a-form-model-item>
          </a-col>

          <a-col
            :md="12"
            :sm="12"
          >
            <a-form-model-item
              label="资质证书编号"
              :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
              :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
              prop="certNum"
            >
              <BaseInput
                v-model="formAdd.certNum"
                :disabled="type == 'view'"
                placeholder="请输入"
              />
            </a-form-model-item>
          </a-col>
          <a-col
            :md="12"
            :sm="12"
          >
            <a-form-model-item
              label="资质等级及承揽项目范围"
              :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
              :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
              prop="certLevelScope"
            >
              <BaseInput
                v-model="formAdd.certLevelScope"
                :disabled="type == 'view'"
                placeholder="请输入"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-modal>
    <!-- 设计资源库 -->
    <a-modal
      width="1000px"
      v-model="visibleRecommand"
      @ok="handleRecommandOk"
      @cancel="visibleRecommand = false"
      title="选择设计资源"
    >
      <a-form-model :model="form">
        <a-row>
          <a-col
            :md="12"
            :sm="12"
          >
            <a-form-model-item
              label="资源名称"
              :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
              :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
            >
              <BaseInput
                v-model="searchQuery.designResourceName"
                placeholder="请输入"
              />
            </a-form-model-item>
          </a-col>
          <a-col
            :md="12"
            :sm="12"
          >
            <a-form-model-item
              label="设计资源等级"
              :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
              :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
            >
              <!-- <BaseInput v-model="searchQuery.resLevelId"  placeholder="请输入" /> -->
              <a-select
                allowClear
                placeholder="请选择"
                v-model="searchQuery.resLevelId"
              >
                <a-select-option
                  v-for="item in recommendLevelOption"
                  :key="item.id"
                  :value="item.id"
                >{{
                  item.name
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col
            :md="12"
            :sm="12"
          >
            <a-form-model-item
              label="分公司"
              :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
              :wrapperCol="{ lg: { span: 18 }, sm: { span: 18 } }"
            >
              <a-select
                allowClear
                placeholder="请选择"
                @change="handleChangeCompany"
                v-model="searchQuery.branchId"
              >
                <a-select-option
                  v-for="item in companys"
                  :key="item.id"
                  :value="item.orgId"
                >{{
                  item.orgName
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col
            :md="12"
            :sm="12"
          >
            <div style="float: right">
              <a-button
                style="margin: 0 20px"
                type="primary"
                @click="getDesignResourcesList"
              >搜索</a-button>
              <a-button @click="getReset">重置</a-button>
            </div>
          </a-col>
        </a-row>
      </a-form-model>
      <a-table
        :columns="columns1"
        :rowSelection="rowSelection"
        :data-source="recommandLists"
      >
        <span
          slot="serial"
          slot-scope="text, record, index"
        >{{ index + 1 }}</span>

        <span
          slot="action"
          slot-scope="text, record"
        >
          <template>
            <a @click="handleSelectSub(record)">选择</a>
          </template>
        </span>
      </a-table>
    </a-modal>
    <selectApprover
      :businessId="businessId"
      :processConfig="setProcessConfig"
      :isCloseUpper="isCloseUpper"
    ></selectApprover>
  </base-breadcrumb>
</template>

<script>
import { getAttachment } from '@/api/commons'
import { STable, Ellipsis } from '@/components'
import { deleteTeamList } from '@/api/subcontractors/labour'
import { getRecommendLevel, addList, editList, getList, getDetails, submit, getCompanyDetails, getExpertList, editCompany, editExpertList, deleteRecommand } from '@/api/design/resourceRecommend/basic'
import designCompany from './components/designCompany'
import designExpert from './components/designExpert'
import overseasCompany from './components/overseasCompany'
import overseasExpert from './components/overseasExpert'
import { getTypesLabel } from '@/api/commons'
import { themeChoose } from '@/mixin/mixin'
import { getDesignResourcesList } from '@/api/design/parameter'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import { isEmail, isPhone, isSocialcredit, createValidator, createValidTool } from '@/utils/regExpression'
import { getCompany } from '@/api/themeChoose/themeChoose'
const columns = [
  {
    title: '序号',
    scopedSlots: { customRender: 'serial' }
  },
  {
    title: '资质类别',
    dataIndex: 'certType'
  },
  {
    title: '资质证书编号',
    dataIndex: 'certNum'
  },
  {
    title: '资质等级及承揽项目范围',
    dataIndex: 'certLevelScope'
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '150px',
    scopedSlots: { customRender: 'action' }
  }
]
const columns1 = [
  {
    title: '序号',
    dataIndex: 'serial',
    scopedSlots: { customRender: 'serial' }
  },
  {
    title: '设计资源名称',
    dataIndex: 'name'
  },
  {
    title: '设计资源类型',
    dataIndex: 'resTypeName'
  },
  {
    title: '资源等级',
    dataIndex: 'resLevelName'
  },
  {
    title: '分公司',
    dataIndex: 'branchName'
  }
]
// 数组创建时候的下标
var numbe = 0

export default {
  name: 'a' + Date.now(),
  mixins: [themeChoose],
  components: {
    STable,
    designCompany,
    designExpert,
    overseasCompany,
    overseasExpert,
    SelectSubCompany
    // Service,
    // Fingernail,
    // Labour
  },
  props: {
    text: String,
    // 是否作为审批详情
    isAudit: {
      type: Boolean,
      default: false
    },
    // 是否作为意见征询
    isConsultation: {
      type: Boolean,
      default: false
    }
  },

  data() {
    return {
      childValidInfo: createValidTool(),
      overseasExpertRules: {
        tel: [{ required: true, message: '请输入联系电话',trigger: 'blur' }],
        email: [{ validator: createValidator(isEmail, '邮箱格式不正确', false, this.validChanged), trigger: 'blur' }]
      },
      overseasRules: {
        legalContact: [{ validator: createValidator(isPhone, '手机号格式不正确', false, this.validChanged), trigger: 'blur' }]
      },
      companyRules: {
        creditCode: [{ validator: createValidator(isSocialcredit, '统一社会信用代码', false, this.validChanged), trigger: 'blur' }],
        legalContact: [{ validator: createValidator(isPhone, '手机号格式不正确', false, this.validChanged), trigger: 'blur' }]
      },
      expertRules: {
        tel: [{ required: true, message: '请输入联系电话',trigger: 'blur' }],
        email: [{ validator: createValidator(isEmail, '邮箱格式不正确', false, this.validChanged), trigger: 'blur' }]
      },
      editTargetIndex: null, // 编辑对象序号
      certRules: {
        certType: [{ required: true, message: '请输入', trigger: 'change' }],
        certNum: [{ required: true, message: '请输入', trigger: 'change' }],
        certLevelScope: [{ required: true, message: '请输入', trigger: 'change' }]
      },
      isSharpSaved: false, // 是否已进行显示保存操作
      // 查询参数
      queryParam: {},
      searchQuery: {},
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return getGroup(requestParameters).then((res) => {
          return res
        })
      },
      loadingGroup: {
        save: false,
        submit: false,
        saveDraft: false,
        submitForm: false
      },
      visible: false,
      selectVisible: false,
      nextSteps: '1',
      formType: '',
      visibleRecommand: false,
      projectLevel: false, //是否为项目部层级
      branchLevel: false, //是否为分公司层级
      companyLevel: false, //是否为公司层级
      confirmLoading: false,
      subcontractorName: '',
      subcontractorId: 1,
      selectDatas: {}, // 立项返回下拉数据
      type: '',
      columns,
      columns1,
      progressing: false,
      editingKey: '',
      loading: false,
      title: '',
      selectedRowKeys: [],
      fileList: [
        {
          uid: '-1',
          name: 'image.png',
          status: 'done',
          url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
        }
      ],
      certifications: [],
      headers: {
        authorization: 'authorization-text'
      },
      form: {
        recommendEmployeeName: '',
        recommendEmployeeId: '',
        createTime: this.getNowTime()
      },
      formList: {},
      status: 'all',
      areaCode: '',
      basicList: {},
      dataList: [],
      id: '',
      disabled: false,
      designTypes: [],
      recommandLists: [],
      isCompany: false,
      formAdd: {},
      userDetail: [],
      isManager: false,
      selectedRows: [],
      typeList: [],
      companyList: [],
      recommendLevelOption: [],
      rules: {
        resName: [{ required: true, message: '请输入推荐设计资源名称', trigger: 'blur' }],
        resTypeId: [{ required: true, message: '请选择推荐类型', trigger: 'change' }],
        resLevelId: [{ required: true, message: '请选择推荐评级', trigger: 'change' }],
        recommendOrgId: [{ required: true, message: '请选择推荐单位', trigger: 'change' }],
        recommendReason: [{ required: true, message: '请输入推荐理由', trigger: 'blur' }]
      },
      companyLists: [],
      branchList: [],
      companys: [],
      //获取流程配置值
      processConfig: null,
      //点击提交发送流程配置值
      setProcessConfig: null,
      businessId: null,
      isCloseUpper: false
    }
  },
  async created() {
    this.id = this.$route.query.id
    this.type = this.$route.query.type
    this.userDetail = JSON.parse(sessionStorage.getItem('ycloud-user_info')).currentPost
    this.form.recommendEmployeeId = JSON.parse(sessionStorage.getItem('ycloud-user_info')).id
    this.form.recommendEmployeeName = JSON.parse(sessionStorage.getItem('ycloud-user_info')).employee.name

    this.getTypesLabel()
    this.getDetails()

    this.branchLevel = this.userDetail.code == 'BC' //分公司级 =
    this.branchList = [this.userDetail]
    this.companyLevel = this.userDetail.code == 'CO' //公司级
    this.companyLists = [this.userDetail]
    this.projectLevel = this.userDetail.code == 'PD' //项目级

    //获取通过获取流程配置值
    this.processConfig = await this.$getConfigFn('design_resource_recommend')
  },
  computed: {
    rowSelection() {
      return {
        type: 'radio',
        selectedRowKeys: this.selectedRowKeys,
        selectedRows: this.selectedRows, // 当前行所有数据
        onChange: this.onSelectChange
      }
    },
    curTitle() {
      const map = {
        add: '新增',
        edit: '编辑',
        view: '查看'
      }
      return map[this.type] || ''
    }
  },
  watch: {
    id() {
      this.registerMultitabCallback()
    },
    formType() {
      // 需要重置validatorTool，避免验证出错
      this.childValidInfo = createValidTool()
    }
  },
  beforeDestroy() {
    this.$multiTab.deleteCallback(this.$route.fullPath)
  },
  methods: {
    getCompany() {
      // const userInfo = Vue.getAcloudProvider().getUserInfo()
      // const orgIds = userInfo.employee&&userInfo.employee.posts.map(p=>p.orgId)
      let that = this
      getCompany({ tagCodes: ['BC', 'CO'] }).then((res) => {
        that.companys = res.data
      })
    },
    handleValidate() {
      // 验证子组件是否有内容填写错误
      const validInfo = this.childValidInfo.validate()
      if (!validInfo.valid) {
        this.$message.warn(validInfo.message)
      }
      return !!validInfo.valid
    },
    validChanged(data) {
      this.childValidInfo.update(data)
    },
    /**
     * 新增页面且已经隐式保存过(id有值)时，注册multiTab回调,用于删除此种情况下生成的冗余数据
     */
    registerMultitabCallback() {
      if (this.id && this.type == 'add') {
        this.$multiTab.registerCallback(this.$route.fullPath, () => {
          this.goBack()
        })
      }
    },
    /**
     * @description 生成记录ID
     */
    createRecordId() {
      const timeStamp = new Date().getTime()
      return `fakeId${timeStamp}`
    },
    getDesignResourcesList() {
      if (this.formType == '设计专家') {
        this.searchQuery.resTypeName = '设计单位'
      } else if (this.formType == '海外设计专家') {
        this.searchQuery.resTypeName = '海外设计单位'
      }
      getDesignResourcesList(this.searchQuery).then((res) => {
        this.recommandLists = res.data
      })
    },
    getReset() {
      this.searchQuery = { resTypeName: this.formType }
      if (this.formType == '设计专家') {
        this.searchQuery.resTypeName = '设计单位'
      } else if (this.formType == '海外设计专家') {
        this.searchQuery.resTypeName = '海外设计单位'
      }
      this.getDesignResourcesList()
    },
    goBack() {
      if (this.type == 'add' && this.isSharpSaved == false && !this.isCloseUpper) {
        let _this = this
        if (_this.id) {
          // 未进行显示保存时，需要执行删除操作
          this.$confirm({
            title: '警告提醒！',
            content: '未进行保存，将删除当前数据，请问是否确认退出？',
            okType: 'danger',
            onOk() {
              deleteRecommand({ id: _this.id }).then((res) => {
                if ((res.code = '200')) {
                  _this.$message.success('删除成功')
                  _this.$router.push('/project/design/resource/recommend')
                }
              })
            },
            onCancel() {
              _this.registerMultitabCallback() // 如果取消了，需要再次注册
            }
          })
        } else {
          this.$confirm({
            title: '警告提醒！',
            content: '未进行保存，将删除当前数据，请问是否确认退出？',
            okType: 'danger',
            onOk() {
              _this.$message.success('删除成功')
              _this.$router.push('/project/design/resource/recommend')
            }
          })
        }
      } else if (this.type != 'approve') {
        this.$router.push('/project/design/resource/recommend')
      } else {
        window.close()
      }
    },
    getDetails() {
      if (this.id) {
        this.progressing = true
        getDetails({ id: this.id })
          .then((res) => {
            this.form = res.data
            this.$set(this.form, 'oldResType', res.data.resTypeId)
            this.progressing = false
            // this.form.recommendEmployeeName = JSON.parse(sessionStorage.getItem('ycloud-user_info')).employee.name
          })
          .catch(() => {
            this.progressing = false
          })
      }
    },
    getTypesLabel() {
      // 推荐类型
      getTypesLabel({ type: '14' }).then((res) => {
        this.typeList = res.data
      })
      // 评级
      getTypesLabel({ type: '13' }).then((res) => {
        this.recommendLevelOption = res.data
      })
      // 职称
      getTypesLabel({ type: '15' }).then((res) => {
        this.titleList = res.data
      })
      // 学历
      getTypesLabel({ type: '16' }).then((res) => {
        this.educationList = res.data
      })
      // 企业性质
      getTypesLabel({ type: '17' }).then((res) => {
        this.companyList = res.data
      })
    },
    clickBtn() {
      this.visibleRecommand = true
      this.getDesignResourcesList()
      this.getCompany()
    },

    choice(type) {
      this.visible = true
      if (type === 'qualified') {
        this.title = '选择合格分包商'
      } else {
        this.title = '选择推荐分包商'
      }
    },
    changeType(value) {
      if (this.id) {
        if (this.form.resTypeId) {
          let _this = this
          _this.$confirm({
            title: '警告提醒！',
            content: '如果切换，则已填写的推荐信息将不再保存',
            okType: 'danger',
            onOk() {
              return false
            },
            onCancel() {
              _this.$set(_this.form, 'resTypeId', _this.form.oldResType)
            }
          })
          return false
        }
      }
    },
    getSubcontractorsList() {
      getSubcontractorsList().then((res) => {
        this.dataList = res.data
      })
    },
    /**
     * 返回前会清除multiTab回调
     */
    plainBack() {
      // this.$multiTab.deleteCallback(this.$route.fullPath)
      this.$close()
    },
    save(isClick = false) {
      if (!this.handleValidate()) return
      if (this.type != 'view' && this.type != 'approve') {
        if (this.formType == '设计单位' || this.formType == '海外设计单位') {
          if (this.formList.certifications) {
            this.formList.certifications.forEach((item) => {
              item.id = null
            })
          }
          this.formList.reCommandId = this.id
          this.formList.certifications = this.formList.certifications
          if (this.formList.natureOfEnterpriseId && this.formList.natureOfEnterpriseId.length == 0) {
            this.formList.natureOfEnterpriseId = null
          }
          if (this.loadingGroup.save) return
          this.loadingGroup.save = true
          editCompany(this.formList)
            .then((res) => {
              this.loadingGroup.save = false
              this.$message.success('保存成功')
              if (isClick) {
                this.isSharpSaved = true
              }
            })
            .catch(() => {
              this.loadingGroup.save = false
            })
        } else if (this.formType == '设计专家' || this.formType == '海外设计专家') {
          this.formList.reCommandId = this.id
          if (this.loadingGroup.save) return
          this.loadingGroup.save = true
          editExpertList(this.formList)
            .then((res) => {
              this.loadingGroup.save = false
              this.$message.success('保存成功')
              if (isClick) {
                this.isSharpSaved = true
              }
            })
            .catch(() => {
              this.loadingGroup.save = false
            })
        }
      }
    },
    submit() {
      this.setProcessConfig = null
      this.businessId = null
      if (!this.handleValidate()) return
      this.submitApprovalConfirm(this.processConfig, (flag)=>{
        if(!flag) {
          return
        }
      if (this.formType == '设计单位' || this.formType == '海外设计单位') {
        this.formList.auditStatus = 'SUBMITTED'
        this.formList.certifications.forEach((item) => {
          item.id = null
        })
        this.formList.reCommandId = this.id
        this.formList.certifications = this.formList.certifications
        if (this.loadingGroup.submit) return
        this.loadingGroup.submit = true
        editCompany(this.formList)
          .then((res) => {
            this.$message.success('提交成功')
            this.businessId = this.id
            this.setProcessConfig = this.processConfig
            this.isCloseUpper = true
          })
          .catch(() => {
            this.loadingGroup.submit = false
          })
      } else if (this.formType == '设计专家' || this.formType == '海外设计专家') {
        this.formList.auditStatus = 'SUBMITTED'
        this.formList.reCommandId = this.id
        if (this.loadingGroup.submit) return
        this.loadingGroup.submit = true
        editExpertList(this.formList)
          .then((res) => {
            this.$message.success('提交成功')
            this.businessId = this.id
            this.setProcessConfig = this.processConfig
            this.isCloseUpper = true
          })
          .catch(() => {
            this.loadingGroup.submit = false
          })
      }
      })
    },
    onChange(value) {},
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows[0]
    },
    employeeNums(val) {
      this.employeeNum = val
    },
    changeTime(value, dateString) {
      this.formList.registrationDate = dateString
    },
    handleQulEdit(record, index) {
      this.editTargetIndex = index
      this.visible = true
      this.formAdd = { ...record }
    },
    handleEdit(record) {
      let _this = this
      _this.form.subcontractorName = record.recommendSubcontractors
    },
    callback(key) {
      // tabs切换
      if (this.type === 'view' || key === '1') {
        this.nextSteps = key
      }
      if (key == 2) {
        this.$refs.ruleForm.validate((valid) => {
          if (valid) {
            this.nextSteps = key // 非查看页面需要校验通过才能跳转
            if (this.id) {
              // 编辑
              this.form.id = this.id
              console.log("====5555")
              editList(this.form).then((res) => {
                if (res.code == 200) {
                  this.formType = res.data.resTypeName
                  this.form.resName = res.data.resName
                  if (res.data.resTypeName == '设计单位' || res.data.resTypeName == '海外设计单位') {
                    getCompanyDetails({ id: this.id }).then((res) => {
                      this.formList = res.data
                      if (!this.formList.certifications) {
                        this.formList.certifications = []
                      }
                      if (this.formList.natureOfEnterpriseId) {
                        if (this.formType == '海外设计单位') {
                          this.formList.natureOfEnterpriseId = null
                        }
                      }
                      if (!this.formList.natureOfEnterpriseId) {
                        this.formList.natureOfEnterpriseId = undefined
                      }
                      if (this.formList.certifications) {
                        this.formList.certifications.forEach((item) => {
                          for (let i = 1; i < 100; i++) {
                            item.id = i
                          }
                        })
                      }
                      this.getTypesLabel()
                    })
                  } else if (res.data.resTypeName == '设计专家' || res.data.resTypeName == '海外设计专家') {
                    getExpertList({ id: this.id }).then((res) => {
                      this.formList = res.data
                      if (!this.formList.maxEducationId) {
                        this.$set(this.formList, 'maxEducationId', undefined)
                        this.educationList = []
                      }
                      if (!this.formList.jobTitleId) {
                        this.$set(this.formList, 'jobTitleId', undefined)
                        this.titleList = []
                      }
                      if (res.code == 200) {
                        this.getTypesLabel()
                      }
                    })
                  }
                }
              })
            } else {
              // 新增
              this.form.auditStatus = 'DRAFT'
              addList(this.form).then((res) => {
                this.id = res.data.id
                if (res.code == 200) {
                  this.form = res.data
                  this.formType = res.data.resTypeName
                  if (res.data.resTypeName == '设计单位' || res.data.resTypeName == '海外设计单位') {
                    getCompanyDetails({ id: this.id }).then((res) => {
                      this.formList = res.data
                      if (!this.formList.certifications) {
                        this.formList.certifications = []
                      }
                      if (res.code == 200) {
                        this.getTypesLabel()
                      }
                    })
                  } else if (res.data.resTypeName == '设计专家' || res.data.resTypeName == '海外设计专家') {
                    getExpertList({ id: this.id }).then((res) => {
                      this.formList = res.data
                      if (!this.formList.maxEducationId) {
                        this.$set(this.formList, 'maxEducationId', undefined)
                        this.educationList = []
                      }
                      if (!this.formList.jobTitleId) {
                        this.$set(this.formList, 'jobTitleId', undefined)
                        this.titleList = []
                      }
                      if (res.code == 200) {
                        this.getTypesLabel()
                      }
                    })
                  }
                }
              })
            }
          } else {
            this.$message.warning('请填写完所有必填项信息')
          }
        })
      } else if (key == 1) {
        this.save()
      }
    },
    handleCancel() {
      let _this = this
      _this.visible = false
      this.$refs.certForm.clearValidate()
    },
    // 保存草稿
    saveDraft(isClick = false) {
      if (!this.handleValidate()) return
      let obj = JSON.parse(sessionStorage.getItem('ycloud-user_info')).currentPost
      if (obj.code == 'CO') {
        this.form.recommendOrgId = obj.id
      }
      if (this.id) {
        this.loadingGroup.saveDraft = true
        editList(this.form)
          .then((res) => {
            this.loadingGroup.saveDraft = false
            if (res.code == '200') {
              if (isClick) {
                this.isSharpSaved = true
              }
              this.$message.success('保存成功')
              this.formType = res.data.resTypeName
              this.$router.push("/project/design/resource/recommend")
            }
          })
          .catch(() => {
            this.loadingGroup.saveDraft = false
          })
      } else {
        this.form.auditStatus = 'DRAFT'
        this.loadingGroup.saveDraft = true
        addList(this.form)
          .then((res) => {
            this.loadingGroup.saveDraft = false
            if (res.code == '200') {
              if (isClick) {
                this.isSharpSaved = true
              }
              this.$message.success('保存成功')
              this.formType = res.data.resTypeName
              this.$router.push("/project/design/resource/recommend")
            }
          })
          .catch(() => {
            this.loadingGroup.saveDraft = false
          })
      }
    },
    // 提交
    submitForm() {
      this.setProcessConfig = null
      this.businessId = null
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          let obj = JSON.parse(sessionStorage.getItem('ycloud-user_info')).currentPost

          if (obj.code == 'CO') {
            this.form.recommendOrgId = obj.id
          }
          this.submitApprovalConfirm(this.processConfig, (flag)=>{
            if(!flag) {
              return
            }
          if (this.id) {
            this.form.auditStatus = 'SUBMITTED'
            this.loadingGroup.submitForm = true
            editList(this.form).then((res) => {
              this.loadingGroup.submitForm = false
              if (res.code == '200') {
                this.$message.success('提交成功')
                this.businessId = res.data.id
                this.setProcessConfig = this.processConfig
                this.isCloseUpper = true
                // this.$router.push("/project/design/resource/recommend")
                this.formType = res.data.resTypeName
              }
            })
          } else {
            this.form.auditStatus = 'SUBMITTED'
            this.loadingGroup.submitForm = true
            addList(this.form).then((res) => {
              this.loadingGroup.submitForm = false
              if (res.code == '200') {
                this.$message.success('提交成功')
                this.businessId = res.data.id
                this.setProcessConfig = this.processConfig
                this.isCloseUpper = true
                // this.$router.push("/project/design/resource/recommend")
                this.formType = res.data.resTypeName
              }
            })
          }
          })
        } else {
          this.$message.warning('请填写完所有必填项信息')
        }
      })
    },
    async nextStep() {
      this.setProcessConfig = null
      let valid = true
      if (this.type !== 'view') {
        valid = await this.$refs.ruleForm.validate()
      }
      if (!valid) {
        this.$message.warning('请填写完所有必填项信息')
        return
      }
      if (this.id) {
        // 编辑
        this.form.id = this.id
        editList({
          ...this.form
        }).then((res) => {
          if (res.code == '200') {
            this.nextSteps = '2'
            this.formType = res.data.resTypeName
            if (res.data.resTypeName == '设计单位' || res.data.resTypeName == '海外设计单位') {
              getCompanyDetails({ id: this.id }).then((res) => {
                this.formList = res.data
                if (!this.formList.certifications) {
                  this.formList.certifications = []
                }
                this.getTypesLabel()
              })
            } else if (res.data.resTypeName == '设计专家' || res.data.resTypeName == '海外设计专家') {
              getExpertList({ id: this.id }).then((res) => {
                this.formList = res.data
                if (!this.formList.maxEducationId) {
                  // this.formList.maxEducationId = ''
                  this.$set(this.formList, 'maxEducationId', undefined)
                  this.educationList = []
                }
                if (!this.formList.jobTitleId) {
                  // this.formList.jobTitleId = ''
                  this.$set(this.formList, 'jobTitleId', undefined)
                  this.titleList = []
                }
                this.getTypesLabel()
              })
            }
          }
        })
      } else {
        // 新增
        this.form.auditStatus = 'DRAFT'
        addList(this.form).then((res) => {
          if (res.code == '200') {
            this.nextSteps = '2'
            this.id = res.data.id
            this.formType = res.data.resTypeName
            if (res.data.resTypeName == '设计单位' || res.data.resTypeName == '海外设计单位') {
              getCompanyDetails({ id: this.id }).then((res) => {
                this.formList = res.data
                this.formList.certifications = res.data.certifications
                if (!this.formList.certifications) {
                  this.formList.certifications = []
                }
                if (res.code == '200') {
                  this.getTypesLabel()
                }
              })
            } else if (res.data.resTypeName == '设计专家' || res.data.resTypeName == '海外设计专家') {
              getExpertList({ id: this.id }).then((res) => {
                this.formList = res.data
                if (!this.formList.maxEducationId) {
                  // this.formList.maxEducationId = ''
                  this.$set(this.formList, 'maxEducationId', undefined)
                  this.educationList = []
                }
                if (!this.formList.jobTitleId) {
                  this.formList.jobTitleId = ''
                  this.$set(this.formList, 'jobTitleId', undefined)
                  this.titleList = []
                }
                if (res.code == '200') {
                  this.getTypesLabel()
                }
              })
            }
          }
        })
      }
    },
    getPopupContainer(triggerNode) {
      return triggerNode.parentNode
    },
    handleRecommandOk() {
      this.visibleRecommand = false
      this.formList.employer = this.selectedRows.name
    },
    addQulList() {
      this.editTargetIndex = null
      this.visible = true
      this.formAdd = {}
    },
    delQulList() {},
    handleOk() {
      this.$refs.certForm.validate((valid) => {
        if (!valid) {
          this.$message.warning('请填写完所有必填项信息')
          return
        }
        this.visible = false
        const list = this.formList.certifications
        if (this.editTargetIndex !== null) {
          list.splice(this.editTargetIndex, 1, this.formAdd)
        } else {
          list.push({
            ...this.formAdd,
            id: this.createRecordId()
          })
        }
      })
    },
    // 删除
    goDel() {
      if (this.selectedRows.length == 0) {
        this.$message.error('请先选择需要删除的资质证书！')
      } else {
        let _this = this
        _this.$confirm({
          title: '警告提醒！',
          content: '确定删除所选资质证书？',
          okType: 'danger',
          onOk() {
            let arr = _this.formList.certifications
            _this.selectedRowKeys.forEach((delItem) => {
              let arr = _this.formList.certifications
              for (let index = arr.length - 1; index >= 0; index--) {
                if (delItem === arr[index].id) {
                  arr.splice(index, 1)
                }
              }
            })
            _this.selectedRows = []
            _this.selectedRowKeys = []
            _this.$message.success('删除成功')
          },
          onCancel() {
            console.log('取消删除')
          }
        })
      }
    }
  }
}
</script>

<style lang="less" scoped>
.wrapper-row {
  padding-left: 55px;
  font-weight: bold;
  letter-spacing: 1px;
}

/deep/ .ant-form-item label {
  font-size: 12px;
}

/deep/ .ant-btn {
  border-radius: 5px;
}

/deep/ .ant-calendar-picker-input.ant-input {
  width: 100%;
}

/deep/ .ant-input {
  /*width: 70%;*/
  border-radius: 5px;
}

/deep/ .ant-card.ant-card-bordered {
  border-radius: 5px;
}

.ant-avatar-lg {
  width: 48px;
  height: 48px;
  line-height: 48px;
}

.list-content-item {
  color: rgba(0, 0, 0, 0.45);
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  margin-left: 40px;
  span {
    line-height: 20px;
  }
  p {
    margin-top: 4px;
    margin-bottom: 0;
    line-height: 22px;
  }
}

.title-name {
  border-left: 5px solid #1890ff;
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 20px;
  padding-left: 15px;
  height: 20px;
  line-height: 20px;
}

/deep/ .table-page-search-wrapper .ant-form-inline .ant-row .ant-col.ant-col-sm-24.ant-col-md-12 {
  padding-left: 80px;
}
/*/deep/ .ant-layout, .ant-layout{*/
/*  padding:0*/
/*}*/
.button {
  margin: 30px 10px 0 10px;
}
/deep/ .ant-card-bordered {
  margin-top: 60px;
}
/deep/ .ant-table-pagination.ant-pagination {
  display: none;
}
</style>

